package com.lsmo.android.carfans.app.view;

import com.lsmo.android.carfans.activity.news.NewsActivity;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.widget.ScrollView;

public class NewsScrollView extends ScrollView {

    private GestureDetector mGestureDetector;
    View.OnTouchListener mGestureListener;

    public NewsScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mGestureDetector = new GestureDetector(new YScrollDetector());
        setFadingEdgeLength(0);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
    	
        return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
    }

 
    public class YScrollDetector extends SimpleOnGestureListener {
  

		//向X轴滑动时，返回false
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
        	
            if(Math.abs(distanceY) >= Math.abs(distanceX)) {
            	
                return true;
            }
            return false;
//        	return true;
        }
    }
        
}
